<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <title>相对定位居中</title>
    <style>
        #container {
            position:relative;
            width:360px;
            left:50%;
            margin-left:-180px;
            border:2px solid red;
        }
    </style>
</head>
<body>
<div id="container">相对定位居中</div>
</body>
</html>